﻿using Autofac;
using Ewell.BizComponent.Service.Model.Request;
using Ewell.BizComponent.Service.Server;
using Ewell.BizComponent.UI.Charge.Constant;
using Ewell.BizComponent.UI.Charge.ViewModel;
using Ewell.BizComponent.UI.Core.Model;
using Ewell.BizComponent.UI.Core.VievModel;
using Ewell.Interface.Common.Model.Common;
using Ewell.Interface.Common.Model.GateWay.Dto.Dict;
using Ewell.Interface.Common.Model.GateWay.GateWayUriInfo;
using Ewell.Interface.Common.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace Ewell.BizComponent.UI.Charge.Views
{
    /// <summary>
    /// ChargeView.xaml 的交互逻辑
    /// </summary>
    public partial class ChargeView : UserControl
    {
        public static readonly DependencyProperty ChargeVmProperty = DependencyProperty
            .Register("chargeVm", typeof(ChargeVm), typeof(ChargeView),
            new FrameworkPropertyMetadata(new ChargeVm()));
        public ChargeVm chargeVm {
            get
            {
                if (this.DataContext?.GetType() != typeof(ChargeVm))
                    return (ChargeVm)GetValue(ChargeVmProperty);
                else
                    return this.DataContext as ChargeVm;
            }
            set { SetValue(ChargeVmProperty, value); }
        }
        public ChargeView()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (chargeVm.preSettlementVm == null)
                chargeVm.preSettlementVm = new PreSettlementVm();
            if (chargeVm.patientVm != null)
            {
                chargeVm.preSettlementVm.patient = chargeVm.patientVm;
            }
            chargeVm.preSettlementViewVisib = Visibility.Collapsed;
            chargeVm.settlementViewVisib = Visibility.Collapsed;
            chargeVm.preSettlementState = SettlementStatus.Running;
            chargeVm.settlementState = SettlementStatus.Wait;
            this.DataContext = chargeVm;
            chargeVm.MoveNext.Execute(this);
        }
    }
}
